package com.chzn.beanPostProcessor;

import com.chzn.component.UserService;
import org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory;
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author houchenkai
 * @Created Date: 2020/10/29 16:05
 * @ClassName
 */
//@Component
public class MyMergedBeanDefinitionPostProcessor implements MergedBeanDefinitionPostProcessor {
	/**
	 * TODO 实例化前回调之后,实例化后回调之前 回调此方法
	 * @see AbstractAutowireCapableBeanFactory#doCreateBean(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, java.lang.Object[])
	 */
	@Override
	public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
            if (UserService.class.equals(beanType)){
            	//设置后在初始化时进行调用
            	beanDefinition.setInitMethodName("init");
			}
	}

	@Override
	public void resetBeanDefinition(String beanName) {

	}
}
